Tidying
rest_inspec =
rest_inspec %>%
janitor::clean_names() %>%
drop_na()
Scatterplot of latitude vs. longitude, colored by grade
rest_inspec %>%
filter(
boro == "Manhattan"
) %>%
mutate(
label = str_c("Grade: ", grade, "\nScore: ", score)
) %>%
plot_ly(
x = ~latitude, y = ~longitude, color = ~grade, text = ~label,
type = "scatter", mode = "markers", alpha = 0.5
)
Box plot; restaurants in Manhattan with pending grades and their scores
rest_inspec %>%
filter(
boro == "Manhattan",
cuisine_description == "Café/Coffee/Tea",
grade == "P"
) %>%
mutate(
dba = fct_reorder(dba, score)
) %>%
plot_ly(
y = ~score, color = ~dba,
type = "box",
colors = "viridis",
width = 650, height = 300
) %>%
layout(
xaxis = list(title = 'Name of Restaurant/Entity'),
yaxis = list(title = 'Score')
)
Frequency of grades for restaurants in Manhattan
rest_inspec %>%
filter(
boro == "Manhattan",
) %>%
count(grade) %>%
mutate(
grade = fct_reorder(grade, n)
) %>%
plot_ly(
x = ~grade, y = ~n, color = ~grade,
type = "bar",
colors = "viridis"
) %>%
layout(
xaxis = list(title = 'Grade'),
yaxis = list(title = 'Count')
)